<!DOCTYPE html>
<html lang=en>
<head>
  <meta charset="utf-8">
  
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-transform" />
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="format-detection" content="telephone=no,email=no,adress=no">
  <!-- Color theme for statusbar -->
  <meta name="theme-color" content="#000000" />
  <!-- 强制页面在当前窗口以独立页面显示,防止别人在框架里调用页面 -->
  <meta http-equiv="window-target" content="_top" />
  
  
  <title>小程序对接微信登录和获取手机号 | Hexo</title>
  <meta name="description" content="问题: 老版的springboot 对接微信获取sessionkey 再次解密获取用户手机号 已经不再支持 这里只写2023新版1.前端调用getPhoneNumber ()2.前端组件button 调用微信接口 即在用户获取授权 后面 再次询问用户是否获取手机号3.这时只需要把得到数据中的code传给后端,后端通过appid和secret访问https:&#x2F;&#x2F;api.weixin.qq.com&#x2F;c">
<meta property="og:type" content="article">
<meta property="og:title" content="小程序对接微信登录和获取手机号">
<meta property="og:url" content="http://example.com/2023/06/19/%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%AF%B9%E6%8E%A5%E5%BE%AE%E4%BF%A1%E7%99%BB%E5%BD%95%E5%92%8C%E8%8E%B7%E5%8F%96%E6%89%8B%E6%9C%BA%E5%8F%B7/index.html">
<meta property="og:site_name" content="Lzb">
<meta property="og:description" content="问题: 老版的springboot 对接微信获取sessionkey 再次解密获取用户手机号 已经不再支持 这里只写2023新版1.前端调用getPhoneNumber ()2.前端组件button 调用微信接口 即在用户获取授权 后面 再次询问用户是否获取手机号3.这时只需要把得到数据中的code传给后端,后端通过appid和secret访问https:&#x2F;&#x2F;api.weixin.qq.com&#x2F;c">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://pic.imgdb.cn/item/6490183e1ddac507cc41e7ee.png">
<meta property="og:image" content="https://pic.imgdb.cn/item/649018fd1ddac507cc42ddb3.png">
<meta property="article:published_time" content="2023-06-19T06:49:01.409Z">
<meta property="article:modified_time" content="2023-06-19T09:13:04.242Z">
<meta property="article:author" content="Liuzhaobo">
<meta property="article:tag" content="Spring Boot">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://pic.imgdb.cn/item/6490183e1ddac507cc41e7ee.png">
  <!-- Canonical links -->
  <link rel="canonical" href="http://example.com/2023/06/19/%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%AF%B9%E6%8E%A5%E5%BE%AE%E4%BF%A1%E7%99%BB%E5%BD%95%E5%92%8C%E8%8E%B7%E5%8F%96%E6%89%8B%E6%9C%BA%E5%8F%B7/index.html">
  
    <link rel="alternate" href="/atom.xml" title="Lzb" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png" type="image/x-icon">
  
  
<link rel="stylesheet" href="/css/style.css">

  
  
  
  
<meta name="generator" content="Hexo 6.3.0"></head>


<body class="main-center" itemscope itemtype="http://schema.org/WebPage">
  <header class="header" itemscope itemtype="http://schema.org/WPHeader">
  <div class="slimContent">
    <div class="navbar-header">
      
      
      <div class="profile-block text-center">
        <a id="avatar" href="https://github.com/cofess" target="_blank">
          <img class="img-circle img-rotate" src="/images/avatar.jpg" width="200" height="200">
        </a>
        <h2 id="name" class="hidden-xs hidden-sm">Lzb</h2>
        <h3 id="title" class="hidden-xs hidden-sm hidden-md">Blog</h3>
        <small id="location" class="text-muted hidden-xs hidden-sm"><i class="icon icon-map-marker"></i> Liuzhaobo, China</small>
      </div>
      
      <div class="search" id="search-form-wrap">

    <form class="search-form sidebar-form">
        <div class="input-group">
            <input type="text" class="search-form-input form-control" placeholder="Search" />
            <span class="input-group-btn">
                <button type="submit" class="search-form-submit btn btn-flat" onclick="return false;"><i class="icon icon-search"></i></button>
            </span>
        </div>
    </form>
    <div class="ins-search">
  <div class="ins-search-mask"></div>
  <div class="ins-search-container">
    <div class="ins-input-wrapper">
      <input type="text" class="ins-search-input" placeholder="Type something..." x-webkit-speech />
      <button type="button" class="close ins-close ins-selectable" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
    </div>
    <div class="ins-section-wrapper">
      <div class="ins-section-container"></div>
    </div>
  </div>
</div>


</div>
      <button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#main-navbar" aria-controls="main-navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
    </div>
    <nav id="main-navbar" class="collapse navbar-collapse" itemscope itemtype="http://schema.org/SiteNavigationElement" role="navigation">
      <ul class="nav navbar-nav main-nav ">
        
        
        <li class="menu-item menu-item-home">
          <a href="/.">
            
            <i class="icon icon-home-fill"></i>
            
            <span class="menu-title">Home</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-archives">
          <a href="/archives">
            
            <i class="icon icon-archives-fill"></i>
            
            <span class="menu-title">Archives</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-categories">
          <a href="/categories">
            
            <i class="icon icon-folder"></i>
            
            <span class="menu-title">Categories</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-tags">
          <a href="/tags">
            
            <i class="icon icon-tags"></i>
            
            <span class="menu-title">Tags</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-repository">
          <a href="/repository">
            
            <i class="icon icon-project"></i>
            
            <span class="menu-title">Repository</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-books">
          <a href="/books">
            
            <i class="icon icon-book-fill"></i>
            
            <span class="menu-title">Books</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-links">
          <a href="/links">
            
            <i class="icon icon-friendship"></i>
            
            <span class="menu-title">Links</span>
          </a>
        </li>
        
        
        <li class="menu-item menu-item-about">
          <a href="/about">
            
            <i class="icon icon-cup-fill"></i>
            
            <span class="menu-title">About</span>
          </a>
        </li>
        
      </ul>
      
	
    <ul class="social-links">
    	
        <li><a href="https://github.com/cofess" target="_blank" title="Github" data-toggle=tooltip data-placement=top><i class="icon icon-github"></i></a></li>
        
        <li><a href="http://weibo.com/cofess" target="_blank" title="Weibo" data-toggle=tooltip data-placement=top><i class="icon icon-weibo"></i></a></li>
        
        <li><a href="https://twitter.com/iwebued" target="_blank" title="Twitter" data-toggle=tooltip data-placement=top><i class="icon icon-twitter"></i></a></li>
        
        <li><a href="https://www.behance.net/cofess" target="_blank" title="Behance" data-toggle=tooltip data-placement=top><i class="icon icon-behance"></i></a></li>
        
        <li><a href="/atom.xml" target="_blank" title="Rss" data-toggle=tooltip data-placement=top><i class="icon icon-rss"></i></a></li>
        
    </ul>

    </nav>
  </div>
</header>

  
    <aside class="sidebar" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    
      <div class="widget">
    <h3 class="widget-title">Board</h3>
    <div class="widget-body">
        <div id="board">
            <div class="content">
                <p>欢迎交流与分享经验!</p>
            </div>
        </div>
    </div>
</div>

    
      
  <div class="widget">
    <h3 class="widget-title">Categories</h3>
    <div class="widget-body">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/JAVA/">JAVA</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E8%8B%A5%E4%BE%9D%E6%A1%86%E6%9E%B6/">若依框架</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/%E9%A1%B9%E7%9B%AE/">项目</a><span class="category-list-count">1</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">Tags</h3>
    <div class="widget-body">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/JAVA/" rel="tag">JAVA</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Spring-Boot/" rel="tag">Spring Boot</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%8B%A5%E4%BE%9D%E6%A1%86%E6%9E%B6/" rel="tag">若依框架</a><span class="tag-list-count">1</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget-body tagcloud">
      <a href="/tags/JAVA/" style="font-size: 13px;">JAVA</a> <a href="/tags/Spring-Boot/" style="font-size: 13px;">Spring Boot</a> <a href="/tags/%E8%8B%A5%E4%BE%9D%E6%A1%86%E6%9E%B6/" style="font-size: 13px;">若依框架</a>
    </div>
  </div>

    
      
  <div class="widget">
    <h3 class="widget-title">Archive</h3>
    <div class="widget-body">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2023/06/">June 2023</a><span class="archive-list-count">3</span></li></ul>
    </div>
  </div>


    
      
  <div class="widget">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget-body">
      <ul class="recent-post-list list-unstyled no-thumbnail">
        
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/categories/%E8%8B%A5%E4%BE%9D%E6%A1%86%E6%9E%B6/">若依框架</a>
              </p>
              <p class="item-title">
                <a href="/2023/06/19/%E8%8B%A5%E4%BE%9D%E6%A1%86%E6%9E%B601/" class="title">若依框架01</a>
              </p>
              <p class="item-date">
                <time datetime="2023-06-19T08:30:24.531Z" itemprop="datePublished">2023-06-19</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/categories/JAVA/">JAVA</a>
              </p>
              <p class="item-title">
                <a href="/2023/06/19/JAVAweb%E5%AF%B9%E6%8E%A5%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98/" class="title">JAVAweb对接微信支付</a>
              </p>
              <p class="item-date">
                <time datetime="2023-06-19T07:53:08.536Z" itemprop="datePublished">2023-06-19</time>
              </p>
            </div>
          </li>
          
          <li>
            
            <div class="item-inner">
              <p class="item-category">
                <a class="category-link" href="/categories/%E9%A1%B9%E7%9B%AE/">项目</a>
              </p>
              <p class="item-title">
                <a href="/2023/06/19/%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%AF%B9%E6%8E%A5%E5%BE%AE%E4%BF%A1%E7%99%BB%E5%BD%95%E5%92%8C%E8%8E%B7%E5%8F%96%E6%89%8B%E6%9C%BA%E5%8F%B7/" class="title">小程序对接微信登录和获取手机号</a>
              </p>
              <p class="item-date">
                <time datetime="2023-06-19T06:49:01.409Z" itemprop="datePublished">2023-06-19</time>
              </p>
            </div>
          </li>
          
      </ul>
    </div>
  </div>
  

    
  </div>
</aside>

  
  
  <aside class="sidebar sidebar-toc collapse   in  " id="collapseToc" itemscope itemtype="http://schema.org/WPSideBar">
  <div class="slimContent">
    <nav id="toc" class="article-toc">
      <h3 class="toc-title">Catalogue</h3>
      <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%97%AE%E9%A2%98-%E8%80%81%E7%89%88%E7%9A%84springboot-%E5%AF%B9%E6%8E%A5%E5%BE%AE%E4%BF%A1%E8%8E%B7%E5%8F%96sessionkey-%E5%86%8D%E6%AC%A1%E8%A7%A3%E5%AF%86%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E6%89%8B%E6%9C%BA%E5%8F%B7-%E5%B7%B2%E7%BB%8F%E4%B8%8D%E5%86%8D%E6%94%AF%E6%8C%81-%E8%BF%99%E9%87%8C%E5%8F%AA%E5%86%992023%E6%96%B0%E7%89%88"><span class="toc-number">1.</span> <span class="toc-text">问题: 老版的springboot 对接微信获取sessionkey 再次解密获取用户手机号 已经不再支持 这里只写2023新版</span></a></li></ol>
    </nav>
  </div>
</aside>

<main class="main" role="main">
  <div class="content">
  <article id="post-小程序对接微信登录和获取手机号" class="article article-type-post" itemscope itemtype="http://schema.org/BlogPosting">
    
    <div class="article-header">
      
        
  
    <h1 class="article-title" itemprop="name">
      小程序对接微信登录和获取手机号
    </h1>
  

      
      <div class="article-meta">
        <span class="article-date">
    <i class="icon icon-calendar-check"></i>
	<a href="/2023/06/19/%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%AF%B9%E6%8E%A5%E5%BE%AE%E4%BF%A1%E7%99%BB%E5%BD%95%E5%92%8C%E8%8E%B7%E5%8F%96%E6%89%8B%E6%9C%BA%E5%8F%B7/" class="article-date">
	  <time datetime="2023-06-19T06:49:01.409Z" itemprop="datePublished">2023-06-19</time>
	</a>
</span>
        
  <span class="article-category">
    <i class="icon icon-folder"></i>
    <a class="article-category-link" href="/categories/%E9%A1%B9%E7%9B%AE/">项目</a>
  </span>

        
  <span class="article-tag">
    <i class="icon icon-tags"></i>
	<a class="article-tag-link-link" href="/tags/Spring-Boot/" rel="tag">Spring Boot</a>
  </span>


        

        <span class="post-comment"><i class="icon icon-comment"></i> <a href="/2023/06/19/%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%AF%B9%E6%8E%A5%E5%BE%AE%E4%BF%A1%E7%99%BB%E5%BD%95%E5%92%8C%E8%8E%B7%E5%8F%96%E6%89%8B%E6%9C%BA%E5%8F%B7/#comments" class="article-comment-link">Comments</a></span>
        
      </div>
    </div>
    <div class="article-entry marked-body" itemprop="articleBody">
      
        <h3 id="问题-老版的springboot-对接微信获取sessionkey-再次解密获取用户手机号-已经不再支持-这里只写2023新版"><a href="#问题-老版的springboot-对接微信获取sessionkey-再次解密获取用户手机号-已经不再支持-这里只写2023新版" class="headerlink" title="问题: 老版的springboot 对接微信获取sessionkey 再次解密获取用户手机号 已经不再支持 这里只写2023新版"></a>问题: 老版的springboot 对接微信获取sessionkey 再次解密获取用户手机号 已经不再支持 这里只写2023新版</h3><p>1.前端调用getPhoneNumber ()<br>2.前端组件button 调用微信接口 即在用户获取授权 后面 再次询问用户是否获取手机号<br>3.这时只需要把得到数据中的code传给后端,后端通过appid和secret访问<a target="_blank" rel="noopener" href="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%7B0%7D&secret=%7B1%7D%E8%8E%B7%E5%8F%96%E5%88%B7%E6%96%B0token">https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&amp;appid={0}&amp;secret={1}获取刷新token</a><br>再携带这个刷新token和前端传给的code调用<a target="_blank" rel="noopener" href="https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=%7B0%7D%E5%B0%B1%E5%8F%AF%E4%BB%A5%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E7%9A%84%E6%89%8B%E6%9C%BA%E5%8F%B7%E4%BA%86">https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token={0}就可以获取用户的手机号了</a><br>(如果觉得麻烦可以直接调用调用<a target="_blank" rel="noopener" href="https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=%7B0%7D">https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token={0}</a>)<br>不需要解密操作<br>这两种方式都可以获取用户的手机号，但第一种有点麻烦，还需要解密。<br>毕竟是有新的而且是更简洁的方式，还是用新的方式比较好，旧的已经被官方弃用。</p>
<p>test代码<br>1.这里需要fastjson和hutool两个依赖，放入pom文件中</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>com.alibaba<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>fastjson<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">version</span>&gt;</span>1.2.72<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">groupId</span>&gt;</span>cn.hutool<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>hutool-all<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">version</span>&gt;</span>5.6.5<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>2.appid和secret放在yml文件中<br><a target="_blank" rel="noopener" href="https://pic.imgdb.cn/item/6490183e1ddac507cc41e7ee.png" title="01"><img src="https://pic.imgdb.cn/item/6490183e1ddac507cc41e7ee.png" alt="01" title="01"></a><br>3.test代码</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Value(&quot;$&#123;weixin.appid&#125;&quot;)</span></span><br><span class="line">    <span class="keyword">private</span> String appid;</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Value(&quot;$&#123;weixin.secret&#125;&quot;)</span></span><br><span class="line">    <span class="keyword">private</span> String secret;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> Object <span class="title function_">getPhoneNumber</span><span class="params">(String code)</span> &#123;</span><br><span class="line"></span><br><span class="line">        <span class="type">String</span> <span class="variable">result</span> <span class="operator">=</span> <span class="literal">null</span>;</span><br><span class="line">        <span class="keyword">try</span> &#123;</span><br><span class="line">            <span class="type">String</span> <span class="variable">url</span> <span class="operator">=</span> <span class="string">&quot;https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&amp;appid=&#123;0&#125;&amp;secret=&#123;1&#125;&quot;</span>;</span><br><span class="line">            <span class="type">String</span> <span class="variable">replaceUrl</span> <span class="operator">=</span> url.replace(<span class="string">&quot;&#123;0&#125;&quot;</span>, appid).replace(<span class="string">&quot;&#123;1&#125;&quot;</span>, secret);</span><br><span class="line">            <span class="type">String</span> <span class="variable">res</span> <span class="operator">=</span> HttpUtil.get(replaceUrl);</span><br><span class="line">            <span class="type">JSONObject</span> <span class="variable">json_token</span> <span class="operator">=</span> JSON.parseObject(res);</span><br><span class="line">            <span class="type">String</span> <span class="variable">access_token</span> <span class="operator">=</span> json_token.getString(<span class="string">&quot;access_token&quot;</span>);</span><br><span class="line"></span><br><span class="line">            <span class="type">String</span> <span class="variable">urlTwo</span> <span class="operator">=</span> <span class="string">&quot;https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=&#123;0&#125;&quot;</span>;</span><br><span class="line">            <span class="type">String</span> <span class="variable">replaceUrlTwo</span> <span class="operator">=</span> urlTwo.replace(<span class="string">&quot;&#123;0&#125;&quot;</span>,access_token);</span><br><span class="line">            HashMap&lt;String, Object&gt; requestParam = <span class="keyword">new</span> <span class="title class_">HashMap</span>&lt;&gt;();</span><br><span class="line">            <span class="comment">// 手机号调用凭证</span></span><br><span class="line">            requestParam.put(<span class="string">&quot;code&quot;</span>, code);</span><br><span class="line">            <span class="type">String</span> <span class="variable">jsonStr</span> <span class="operator">=</span> JSON.toJSONString(requestParam);</span><br><span class="line">            <span class="type">HttpResponse</span> <span class="variable">response</span> <span class="operator">=</span> HttpRequest.post(replaceUrlTwo)</span><br><span class="line">                    .header(Header.CONTENT_ENCODING, <span class="string">&quot;UTF-8&quot;</span>)</span><br><span class="line">                    <span class="comment">// 发送json数据需要设置contentType</span></span><br><span class="line">                    .header(Header.CONTENT_TYPE, <span class="string">&quot;application/x-www-form-urlencoded&quot;</span>)</span><br><span class="line">                    .body(jsonStr)</span><br><span class="line">                    .execute();</span><br><span class="line">            <span class="keyword">if</span> (response.getStatus() == HttpStatus.HTTP_OK) &#123;</span><br><span class="line">                result = response.body();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125; <span class="keyword">catch</span> (HttpException e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">return</span> JSONObject.parseObject(result).get(<span class="string">&quot;phone_info&quot;</span>);</span><br></pre></td></tr></table></figure>

<p>4.<a target="_blank" rel="noopener" href="https://pic.imgdb.cn/item/649018fd1ddac507cc42ddb3.png" title="02"><img src="https://pic.imgdb.cn/item/649018fd1ddac507cc42ddb3.png" alt="02" title="02"></a></p>

      
    </div>
    <div class="article-footer">
      <blockquote class="mt-2x">
  <ul class="post-copyright list-unstyled">
    
    <li class="post-copyright-link hidden-xs">
      <strong>本文链接：</strong>
      <a href="http://example.com/2023/06/19/%E5%B0%8F%E7%A8%8B%E5%BA%8F%E5%AF%B9%E6%8E%A5%E5%BE%AE%E4%BF%A1%E7%99%BB%E5%BD%95%E5%92%8C%E8%8E%B7%E5%8F%96%E6%89%8B%E6%9C%BA%E5%8F%B7/" title="小程序对接微信登录和获取手机号" target="_blank" rel="external">http://example.com/2023/06/19/小程序对接微信登录和获取手机号/</a>
    </li>
    
    <li class="post-copyright-license">
      <strong>版权声明： </strong> 本博客所有文章除特别声明外，均采用 <a href="http://creativecommons.org/licenses/by/4.0/deed.zh" target="_blank" rel="external">CC BY 4.0 CN协议</a> 许可协议。转载请注明出处！
    </li>
  </ul>
</blockquote>


<div class="panel panel-default panel-badger">
  <div class="panel-body">
    <figure class="media">
      <div class="media-left">
        <a href="https://github.com/cofess" target="_blank" class="img-burn thumb-sm visible-lg">
          <img src="/images/avatar.jpg" class="img-rounded w-full" alt="">
        </a>
      </div>
      <div class="media-body">
        <h3 class="media-heading"><a href="https://github.com/cofess" target="_blank"><span class="text-dark">Lzb</span><small class="ml-1x">Blog</small></a></h3>
        <div>吾将上下而求索</div>
      </div>
    </figure>
  </div>
</div>


    </div>
  </article>
  
    
  <section id="comments">
  	
      <div id="vcomments"></div>
    
  </section>


  
</div>

  <nav class="bar bar-footer clearfix" data-stick-bottom>
  <div class="bar-inner">
  
  <ul class="pager pull-left">
    
    <li class="prev">
      <a href="/2023/06/19/JAVAweb%E5%AF%B9%E6%8E%A5%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98/" title="JAVAweb对接微信支付"><i class="icon icon-angle-left" aria-hidden="true"></i><span>&nbsp;&nbsp;Newer</span></a>
    </li>
    
    
    
    <li class="toggle-toc">
      <a class="toggle-btn " data-toggle="collapse" href="#collapseToc" aria-expanded="false" title="Catalogue" role="button">    <span>[&nbsp;</span><span>Catalogue</span>
        <i class="text-collapsed icon icon-anchor"></i>
        <i class="text-in icon icon-close"></i>
        <span>]</span>
      </a>
    </li>
    
  </ul>
  
  
  <!-- Button trigger modal -->
  <button type="button" class="btn btn-fancy btn-donate pop-onhover bg-gradient-warning" data-toggle="modal" data-target="#donateModal"><span>$</span></button>
  <!-- <div class="wave-icon wave-icon-danger btn-donate" data-toggle="modal" data-target="#donateModal">
    <div class="wave-circle"><span class="icon"><i class="icon icon-bill"></i></span></div>
  </div> -->
  
  
  <div class="bar-right">
    
    <div class="share-component" data-sites="weibo,qq,wechat,facebook,twitter" data-mobile-sites="weibo,qq,qzone"></div>
    
  </div>
  </div>
</nav>
  
<!-- Modal -->
<div class="modal modal-center modal-small modal-xs-full fade" id="donateModal" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content donate">
      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      <div class="modal-body">
        <div class="donate-box">
          <div class="donate-head">
            <p>Maybe you could buy me a cup of coffee.</p>
          </div>
          <div class="tab-content">
            <div role="tabpanel" class="tab-pane fade active in" id="alipay">
              <div class="donate-payimg">
                <img src="/images/donate/alipayimg.png" alt="Scan Qrcode" title="Scan" />
              </div>
              <p class="text-muted mv">Scan this qrcode</p>
              <p class="text-grey">Open alipay app scan this qrcode, buy me a coffee!</p>
            </div>
            <div role="tabpanel" class="tab-pane fade" id="wechatpay">
              <div class="donate-payimg">
                <img src="/images/donate/wechatpayimg.png" alt="Scan Qrcode" title="Scan" />
              </div>
              <p class="text-muted mv">Scan this qrcode</p>
              <p class="text-grey">Open wechat app scan this qrcode, buy me a coffee!</p>
            </div>
          </div>
          <div class="donate-footer">
            <ul class="nav nav-tabs nav-justified" role="tablist">
              <li role="presentation" class="active">
                <a href="#alipay" id="alipay-tab" role="tab" data-toggle="tab" aria-controls="alipay" aria-expanded="true"><i class="icon icon-alipay"></i> alipay</a>
              </li>
              <li role="presentation" class="">
                <a href="#wechatpay" role="tab" id="wechatpay-tab" data-toggle="tab" aria-controls="wechatpay" aria-expanded="false"><i class="icon icon-wepay"></i> wechat payment</a>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>



</main>

  <footer class="footer" itemscope itemtype="http://schema.org/WPFooter">
	
	
    <ul class="social-links">
    	
        <li><a href="https://github.com/cofess" target="_blank" title="Github" data-toggle=tooltip data-placement=top><i class="icon icon-github"></i></a></li>
        
        <li><a href="http://weibo.com/cofess" target="_blank" title="Weibo" data-toggle=tooltip data-placement=top><i class="icon icon-weibo"></i></a></li>
        
        <li><a href="https://twitter.com/iwebued" target="_blank" title="Twitter" data-toggle=tooltip data-placement=top><i class="icon icon-twitter"></i></a></li>
        
        <li><a href="https://www.behance.net/cofess" target="_blank" title="Behance" data-toggle=tooltip data-placement=top><i class="icon icon-behance"></i></a></li>
        
        <li><a href="/atom.xml" target="_blank" title="Rss" data-toggle=tooltip data-placement=top><i class="icon icon-rss"></i></a></li>
        
    </ul>

    <div class="copyright">
    	
        <div class="publishby">
        	Theme by <a href="https://github.com/cofess" target="_blank"> cofess </a>base on <a href="https://github.com/cofess/hexo-theme-pure" target="_blank">pure</a>.
        </div>
    </div>
</footer>
  <script src="//cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script>
window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')
</script>

<script src="/js/plugin.min.js"></script>


<script src="/js/application.js"></script>


    <script>
(function (window) {
    var INSIGHT_CONFIG = {
        TRANSLATION: {
            POSTS: 'Posts',
            PAGES: 'Pages',
            CATEGORIES: 'Categories',
            TAGS: 'Tags',
            UNTITLED: '(Untitled)',
        },
        ROOT_URL: '/',
        CONTENT_URL: '/content.json',
    };
    window.INSIGHT_CONFIG = INSIGHT_CONFIG;
})(window);
</script>

<script src="/js/insight.js"></script>






   




   
    
  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/valine"></script>
  <script type="text/javascript">
  var GUEST = ['nick', 'mail', 'link'];
  var meta = 'nick,mail,link';
  meta = meta.split(',').filter(function(item) {
    return GUEST.indexOf(item) > -1;
  });
  new Valine({
    el: '#vcomments',
    verify: false,
    notify: false,
    appId: '',
    appKey: '',
    placeholder: 'Just go go',
    avatar: 'mm',
    meta: meta,
    pageSize: '10' || 10,
    visitor: false
  });
  </script>

     







</body>
</html>